/**
 * @Date 2023-02-09 17:14:09
 * @Remark
 */

// config
// state
import { makeAutoObservable, toJS } from "mobx";
// controller
// script & methods & public
import { PAGE_DEFAULT } from "config/setting";
// 其它
// import { Dayjs } from "dayjs";

export interface SearchValue {
  // phoneNumber?: string;
  // sName?: string;
  // sNickname?: string;
  // sMobile?: string;
  // sIdcard?: string;
  // sDate?: Dayjs[];
  // sTeam?: string;
  // sIsTeam?: number;
}

class State {
  loading = false;
  list: UserDto[] = [];
  total = 0;
  page = PAGE_DEFAULT.BEGIN;
  size = PAGE_DEFAULT.SIZE;
  search: SearchValue = {};
  editModal: UserDto | boolean = false;
  remarkEditModal: any | boolean = false;
  courierEditModal: any | boolean = false;
  editModalLoading = false;
  footprintModal: UserDto | boolean = false;
  footprintModalLoading = false;
  idModal: UserDto | boolean = false;
  idModalLoading = false;
  shopList: any[] = [];
  constructor() {
    makeAutoObservable(this);
  }
  setSearch(val: SearchValue = {}) {
    this.search = val;
  }
  getSearch() {
    return toJS(this.search);
  }
  getList() {
    return toJS(this.list);
  }
  setPage(val = PAGE_DEFAULT.BEGIN) {
    this.page = val;
  }
  setSize(val = PAGE_DEFAULT.SIZE) {
    this.size = val;
  }
  getShopList() {
    return toJS(this.shopList);
  }
  get editModalShow() {
    return !!this.editModal;
  }
  get editInfo() {
    if (typeof this.editModal !== "boolean") {
      return toJS(this.editModal);
    }
    return null;
  }
  get remarkEditModalShow() {
    return !!this.remarkEditModal;
  }
  get remarkEditInfo() {
    if (typeof this.remarkEditModal !== "boolean") {
      return toJS(this.remarkEditModal);
    }
    return null;
  }
  get courierEditModalShow() {
    return !!this.courierEditModal;
  }
  get courierEditInfo() {
    if (typeof this.courierEditModal !== "boolean") {
      return toJS(this.courierEditModal);
    }
    return null;
  }
  get footprintModalShow() {
    return !!this.footprintModal;
  }
  get footprintInfo() {
    if (typeof this.footprintModal !== "boolean") {
      return toJS(this.footprintModal);
    }
    return null;
  }
  get idModalShow() {
    return !!this.idModal;
  }
  get idInfo() {
    if (typeof this.idModal !== "boolean") {
      return toJS(this.idModal);
    }
    return null;
  }
}

export const state = new State();
